class ImagesController < ApplicationController
  record_select :per_page => 5, :search_on => :tag_list, :label => :preview

  active_scaffold do |config|
    config.columns = :title, :filename, :tag_list, :related_images

    list.columns.exclude :related_images
    create.columns.exclude :related_images
    update.columns.exclude :related_images
    #show.columns.exclude :nil
  end

  def select
    @selections = params[:id].to_s.split("_")
    limit = (params[:limit] || 20).to_i
    offset = (params[:offset] || 0).to_i
    options = {:limit => limit, :offset => offset}

    @images = (params[:tags]) ? Image.find_tagged_with(params[:tags], options) : 
      Image.find(:all, options)
    @offset = limit + offset
    @limit = (@images.length < limit) ? 0 : limit

    render :layout => false
  end

  # active_scaffold callbacks
  def conditions_for_collection()
  end

  def before_create_save(record)
  end

  def after_create_save(record)
  end
  
  def before_update_save(record)
  end

  def after_update_save(record)
  end
end
